/**
 * 自我实现阻塞队列
 */
class MyBlockQueue {
    private String[] elems = null;
    private int head = 0;//头位置
    private int tail = 0;//插入位置
    private int size = 0;//数组个数
    public MyBlockQueue(int capacity) {
        elems = new String[capacity];
    }
    //插入
    void put(String  elem) {
        if(size >= elems.length) {
            return;
        }
        elems[tail] = elem;
        tail++;
        if(tail >= elems.length) {
            tail = 0;
        }
        size++;
    }
    //取出
    String take() {
        if(size == 0) {
            return null;
        }
        String ret = elems[head];
        head++;
        if(head >= elems.length) {
            head = 0;
        }
        size--;
        return ret;
    }
}
class Demo {
    public static void main(String[] args) {

    }
}
